package com.ruoyi.dynamic.controller.app;


import com.ruoyi.common.core.constant.constant.PathConstant;
import com.ruoyi.common.core.context.SecurityContextHolder;
import com.ruoyi.common.core.pojo.result.Pages;
import com.ruoyi.common.core.pojo.vo.BaseVO;
import com.ruoyi.common.core.pojo.vo.PageVO;
import com.ruoyi.common.core.result.Result;
import com.ruoyi.dynamic.model.pojo.request.app.*;
import com.ruoyi.dynamic.model.pojo.result.app.AppRoomProgramInfoResult;
import com.ruoyi.dynamic.service.IRoomProgramService;
import com.ruoyi.dynamic.service.IRoomService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springdoc.api.annotations.ParameterObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


@Tag(name = "App-房间节目单相关", description = "App-房间节目单相关")
@RestController
@RequestMapping(PathConstant.APP_PATH + "program")
public class AppRoomProgramController {

    @Autowired
    private IRoomService iRoomService;

    @Autowired
    private IRoomProgramService iRoomProgramService;


    @Operation(summary = "房间节目单", description = "房间节目单")
    @GetMapping("programList")
    public PageVO<AppRoomProgramInfoResult> programList(@ParameterObject @Validated AppRoomSingSearchRequest pageSearchParam) {
        Long userId = SecurityContextHolder.getUserId();
        Pages<AppRoomProgramInfoResult> pages = iRoomProgramService.programList(pageSearchParam, userId);
        return Result.page(pages);
    }


    @Operation(summary = "添加编辑节目单", description = "添加编辑节目单")
    @PostMapping("addOrEdit")
    public BaseVO addOrEdit(@RequestBody @Validated AppRoomProgarmAddOrEditRequest request) {
        Long userId = SecurityContextHolder.getUserId();
        boolean add = iRoomProgramService.addOrEdit(request);
        return Result.successOrFail(add);
    }


    @Operation(summary = "删除节目单", description = "删除节目单")
    @PostMapping("remove")
    public BaseVO remove(@RequestBody @Validated AppRoomSingDelRequest request) {
        Long userId = SecurityContextHolder.getUserId();
        boolean add = iRoomProgramService.removeProgram(request, userId);
        return Result.successOrFail(add);
    }


    @Operation(summary = "开启节目单", description = "开启节目单")
    @PostMapping("start")
    public BaseVO start(@RequestBody @Validated AppRoomWishCloseRequest request) {
        Long userId = SecurityContextHolder.getUserId();
        boolean add = iRoomProgramService.startProgram(request, userId);
        return Result.successOrFail(add);
    }


    @Operation(summary = "关闭节目单", description = "关闭节目单")
    @PostMapping("stop")
    public BaseVO stop(@RequestBody @Validated AppRoomWishCloseRequest request) {
        Long userId = SecurityContextHolder.getUserId();
        boolean add = iRoomProgramService.stopProgram(request, userId);
        return Result.successOrFail(add);
    }


    @Operation(summary = "想看", description = "想看")
    @PostMapping("wantLook")
    public BaseVO wantLook(@RequestBody @Validated AppRoomSingDelRequest request) {
        boolean add = iRoomProgramService.wantLook(request, SecurityContextHolder.getUserId());
        return Result.successOrFail(add);
    }


}

